1、新建client同步应用

2、引入依赖
<groupId>com.asura</groupId>
<artifactId>asura-ops-sync-sdk</artifactId>
<version>0.0.2-SNAPSHOT</version>

3、配置多数据源
ops.target.dataSourceProperties[0].url = jdbc:mysql://test.db8-01-asura.ruigushop.com:3306/asura_wms_004?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
ops.target.dataSourceProperties[0].username = asura
ops.target.dataSourceProperties[0].password = asura
ops.target.dataSourceProperties[0].type = com.alibaba.druid.pool.DruidDataSource

ops.target.dataSourceProperties[1].url = jdbc:mysql://test.db8-01-asura.ruigushop.com:3306/asura_wms_005?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
ops.target.dataSourceProperties[1].username = asura
ops.target.dataSourceProperties[1].password = asura
ops.target.dataSourceProperties[1].type = com.alibaba.druid.pool.DruidDataSource

3、新建个类实现AbstractSyncHandler接口

@Slf4j
@Component
public class IBSSyncHandler extends AbstractSyncHandler<Object> {

    @Resource
    private DataSourceConfig dataSourceConfig;

    @PostConstruct
    public void init() {
        Map<String, Class> maps = Maps.newConcurrentMap();
        maps.put("mdm_sku", SkuEntity.class);
        maps.put("mdm_sku_packing_define", MdmSkuPackingDefineEntity.class);

        this.configTableEntityClassMap(maps);
        this.configDatasourceList(dataSourceConfig.dataSourceList());
    }
}

4、数据配置参考 DataSourceConfig

@Component
@Data
@ConfigurationProperties(prefix = "ops.target")
public class DataSourceConfig {

    private List<DataSourceProperties> dataSourceProperties;

    public List<DataSource> dataSourceList() {

        List<DataSource> dataSourceList = Lists.newArrayList();
        for (DataSourceProperties properties : dataSourceProperties) {
            DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
            dataSource.setDriverClassName(properties.getDriverClassName());
            dataSource.setUrl(properties.getUrl());
            dataSource.setUsername(properties.getUsername());
            dataSource.setPassword(properties.getPassword());
            dataSource.setValidationQuery("SELECT 1");//用来检测连接是否有效
            dataSource.setTestOnBorrow(false);
            dataSource.setTestOnReturn(false);
            dataSource.setTestWhileIdle(true);
            dataSource.setTimeBetweenEvictionRunsMillis(600000);
            dataSource.setMaxActive(20);
            dataSource.setInitialSize(10);

            dataSourceList.add(dataSource);
        }
        return dataSourceList;

    }
}

5、把要同步的表的实体copy到应用中，比如SkuEntity,MdmSkuPackingDefineEntity 类




